<template>
  <PageWrapper contentFullHeight dense class="dashboard-container">
    <Spin tio="加载中...">
      <div class="header">
        <div class="header-left"></div>
        <div class="header-right">
          <Time :value="state.time" mode="datetime" align-type="column" :step="1" />
          <a-tooltip placement="bottom" title="前往后台">
            <a-button
              type="primary"
              style="margin-left: 8px"
              size="small"
              :icon="h(ArrowRightOutlined)"
              @click="
                state.spinning = true;
                $router.push({ name: 'devcieBasic' });
              "
            />
          </a-tooltip>
        </div>
      </div>
      <div class="alarm-count"></div>
      <div class="content-left">
        <div class="item-box">
          <div class="item-title">设备状态统计</div>
          <div class="item-content">
            <DeviceStatus :data="state.deviceStatus" />
          </div>
        </div>
        <div class="item-box">
          <div class="item-title">最新告警</div>
        </div>
      </div>
      <div class="content-right">
        <div class="item-box">
          <div class="item-title">销售接入数据对比</div>
        </div>
        <div class="item-box">
          <div class="item-title">各省设备量排行</div>
        </div>
      </div>
      <Map />
    </Spin>
  </PageWrapper>
</template>

<script lang="ts" setup>
  import { ArrowRightOutlined } from '@ant-design/icons-vue';
  // onMounted, onBeforeUnmount, watch, computed, ref, nextTick,
  import { reactive, h } from 'vue';
  import { PageWrapper } from '/@/components/Page';
  import { Time } from '/@/components/Time';
  import DeviceStatus from './deviceStatus.vue';
  import Map from './map.vue';

  const state = reactive({
    startVal: 0,
    endVal: 0,
    alarmList: [],
    rankList: [],
    accessList: [],
    deviceStatus: [],
    saleAccess: [],
    timer: null,
    time: Date.now(),
    mapComplete: false,
    spinning: true,
    current: '', // 有值时表示当前选中省，为空时表示全国
  });
</script>

<style lang="less" scoped>
  .dashboard-container {
    position: relative;
    width: 100%;
    color: #fff;

    .header {
      position: absolute;
      z-index: 50;
      width: 100%;
      height: 8vh;
      top: 0;
      left: 0;
      background-image: url('/@/assets/svg/header.svg');
      background-repeat: no-repeat;
      background-size: 100% 100%;
      display: flex;
      justify-content: space-between;
      padding: 3.5vh 1% 0 1%;
      .header-left {
      }
      .header-right {
        display: flex;
      }
    }
    .alarm-count {
      position: absolute;
      left: 50%;
      top: 9vh;
      transform: translateX(-50%);
      color: #b8d1e5;
      z-index: 600;
      font-size: 1.8vh;
    }
    .content-left,
    .content-right {
      position: absolute;
      z-index: 50;
      top: 8vh;
      height: 90vh;
      width: 22vw;
      background: rgba(0, 0, 0, 0.3);
      .item-box {
        .item-title {
          background-image: url('/@/assets/images/title-bg.png');
          background-repeat: no-repeat;
          background-size: 100% 100%;
          width: 100%;
          height: 3.5vh;
          color: #fff;
          line-height: 2vh;
          font-size: 1.9vh;
          padding-left: 9%;
        }
        .item-content {
          .alarm-row {
            display: flex;
            justify-content: space-between;
            margin-top: 5px;
            padding: 0 2%;
            color: #c8c8c8;
            font-size: 0.55vw;
            // span {
            //   display: inline;
            //   width: 32%;
            //   overflow: hidden;
            //   text-overflow: ellipsis;
            //   white-space: nowrap;
            // }
          }

          .rank-item {
            padding: 0 3%;
            margin-top: 5px;
            .rank-row {
              display: flex;
              justify-content: space-between;
            }
            &:nth-child(1) {
              color: #77deff;
            }
            &:nth-child(2) {
              color: #77ffce;
            }
            &:nth-child(3) {
              color: #9aff77;
            }
          }
        }
      }
      .item-box:nth-child(1) {
        height: 35vh;
      }
    }
    .content-left {
      left: 0;
      padding-left: 0.5%;
    }
    .content-right {
      right: 0;
      padding-right: 0.5%;
      .item-box:nth-child(2) {
        .item-content {
          height: 51.5vh;
          overflow: scroll;
          &::-webkit-scrollbar {
            height: 0 !important;
          }
        }
      }
    }
  }
</style>
